package com.chat.service;

import com.chat.Local;
import com.chat.common.Group;
import com.chat.common.Message;
import com.chat.common.MessageType;
import com.chat.common.User;
import com.chat.view.FriendListData;
import com.chat.view.GroupVerifyView;
import javafx.application.Platform;

import java.util.ArrayList;

import static com.chat.view.MainWindowController.friend;

/*
  拉取群列表
 */
public class GetGroupList {
    public void getgrouplist() {
        Message msg=new Message();
        User user=new User();
        user.setUsername(Local.user.getUsername());
        msg.setData(user);
        msg.setMesType(MessageType.MESSAGE_GET_GROUP_LIST);
        ClientConnectServerThread clientConnectServerThread=ManageClientConnectServerThread.getClientConnectServerThread(Local.user.getUsername());
        clientConnectServerThread.send(msg);
    }
    public void setGroupList(ArrayList<Group> a){
        Platform.runLater(new Runnable() {
            @Override
            public void run() {
                for(int i=0;i<a.size();i++)
                {
                    friend.add(new FriendListData(a.get(i).getName(),a.get(i).getId(),a.get(i).getInfo(),"0","1"));
                }
            }
        });

    }
}
